﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace GylCSharpUtils.Common.Utils {
    public class HashUtils {


        private HashUtils() { }

        public static ulong ComputeHash64(byte[] data ) {
            var hasher = xxHash64.Create();
            return BitConverter.ToUInt64(hasher.ComputeHash(data), 0); 
        }
        public static uint ComputeHash32(byte[] data) {
            var hasher = xxHash32.Create();
            return BitConverter.ToUInt32(hasher.ComputeHash(data), 0); 
        }

        public static ulong ComputeHash64(string str) {
            byte[] data = Encoding.UTF8.GetBytes(str);
            return ComputeHash64(data);
        }
        public static uint ComputeHash32(string str) {
            byte[] data = Encoding.UTF8.GetBytes(str);
            return ComputeHash32(data);
        }
    }
}
